package com.baidu.emus;

/**
 * 用户组
 * @author iicm
 * 2016-2-23 10:34
 */
public enum UserGroup implements BaseEnum<Integer> {
    superAdmin(0, "超级管理员" ),//超级管理员
    vip(1, "Vip用户"),//vip用户
    normal(2, "免费用户");//免费用户

	private int code;

	private String description;

	private UserGroup(int _code, String description) {
		this.code = _code;
		this.description = description;
	}

	public Integer getCode() {
		return this.code;
	}

	public String getDescription() {
		return description;
	}

	@Override
	public String toString() {

		return String.valueOf(this.code);

	}

	// 通过属性获取对象
	public static UserGroup getErrorCode(int code) {

		for (UserGroup obj : UserGroup.values()) {
			if (code == obj.getCode()) {

				return obj;
			}
		}

		return null;

	}

	public static String getName(int code) {

		for (UserGroup obj : UserGroup.values()) {
			if (code == obj.getCode()) {

				return obj.name();
			}
		}

		return null;

	}

	public static String getDescription(int code) {

		for (UserGroup obj : UserGroup.values()) {
			if (code == obj.getCode()) {

				return obj.getDescription();
			}
		}
		return null;

	}
}
